home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / vindictr.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  14KB  |  456 lines

  1. /***************************************************************************
  2.  
  3. vindictr Memory Map
  4. ----------------
  5.  
  6. driver by Aaron Giles
  7.  
  8.  
  9. vindictr 68010 MEMORY MAP
  10.  
  11. Program ROM             000000-09FFFF   R    D15-D0
  12.  
  13. EEPROM                  0E0001-0E0FFF  R/W   D7-D0    (odd bytes only)
  14. Program RAM             160000-16FFFF  R/W   D15-D0
  15. UNLOCK EEPROM           1Fxxxx          W
  16.  
  17. Player 1 Input (left)   260000          R    D11-D8 Active lo
  18. Player 2 Input (right)  260010          R    D11-D8 Active lo
  19.       D8:    start
  20.       D9:    fire
  21.       D10:   spare
  22.       D11:   duck
  23.  
  24. VBLANK                  260010          R    D0 Active lo
  25. Self-test                               R    D1 Active lo
  26. Input buffer full (@260030)             R    D2 Active lo
  27. Output buffer full (@360030)            R    D3 Active lo
  28. ADEOC, end of conversion                R    D4 Active hi
  29.  
  30. ADC0, analog port       260020          R    Start
  31.  
  32. Read sound processor    260030          R    D0-D7
  33. Watch Dog               2E0000          W    xx        (128 msec. timeout)
  34. VBLANK Interrupt ack.   360000          W    xx
  35.  
  36. Video off               360010          W    D5 (active hi)
  37. Video intensity                         W    D1-D4 (0=full on)
  38. EXTRA cpu reset                         W    D0 (lo to reset)
  39.  
  40. Sound processor reset   360020          W    xx
  41. Write sound processor   360030          W    D0-D7
  42.  
  43. Color RAM Alpha         3E0000-3E01FF  R/W   D15-D0
  44. Color RAM Motion Object 3E0200-3E03FF  R/W   D15-D0
  45. Color RAM Playfield     3E0400-3E07FE  R/W   D15-D0
  46. Color RAM STAIN         3E0800-3E0FFE  R/W   D15-D0
  47.  
  48. Playfield Picture RAM   3F0000-3F1FFF  R/W   D15-D0
  49. Motion Object RAM       3F2000-3F3FFF  R/W   D15-D0
  50. Alphanumerics RAM       3F4000-3F4EFF  R/W   D15-D0
  51. Scroll and MOB config   3F4F00-3F4F70  R/W   D15-D0
  52. SLIP pointers           3F4F80-3F4FFF  R/W   D9-D0
  53. Working RAM             3F5000-3F7FFF  R/W   D15-D0
  54.  
  55. Playfield Picture RAM   FF8000-FF9FFF  R/W   D15-D0
  56. Motion Object RAM       FFA000-FFBFFF  R/W   D15-D0
  57. Alphanumerics RAM       FFC000-FFCEFF  R/W   D15-D0
  58. Scroll and MOB config   FFCF00-FFCF70  R/W   D15-D0
  59. SLIP pointers           FFCF80-FFCFFF  R/W   D9-D0
  60. Working RAM             FFD000-FFFFFF  R/W   D15-D0
  61.  
  62. ****************************************************************************/
  63.  
  64.  
  65.  
  66. #include "driver.h"
  67. #include "machine/atarigen.h"
  68. #include "sndhrdw/atarijsa.h"
  69. #include "vidhrdw/generic.h"
  70.  
  71.  
  72. WRITE_HANDLER( vindictr_playfieldram_w );
  73. WRITE_HANDLER( vindictr_paletteram_w );
  74.  
  75. int vindictr_vh_start(void);
  76. void vindictr_vh_stop(void);
  77. void vindictr_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  78.  
  79. void vindictr_scanline_update(int scanline);
  80.  
  81.  
  82.  
  83. /*************************************
  84.  *
  85.  *    Shared RAM handling
  86.  *
  87.  *************************************/
  88.  
  89. static UINT8 *shared_ram_4;
  90.  
  91. static READ_HANDLER( shared_ram_1_r ) { return READ_WORD(&atarigen_playfieldram[offset]); }
  92. static READ_HANDLER( shared_ram_2_r ) { return READ_WORD(&atarigen_spriteram[offset]); }
  93. static READ_HANDLER( shared_ram_3_r ) { return READ_WORD(&atarigen_alpharam[offset]); }
  94. static READ_HANDLER( shared_ram_4_r ) { return READ_WORD(&shared_ram_4[offset]); }
  95.  
  96. static WRITE_HANDLER( shared_ram_1_w ) { COMBINE_WORD_MEM(&atarigen_playfieldram[offset], data); }
  97. static WRITE_HANDLER( shared_ram_2_w ) { COMBINE_WORD_MEM(&atarigen_spriteram[offset], data); }
  98. static WRITE_HANDLER( shared_ram_3_w ) { COMBINE_WORD_MEM(&atarigen_alpharam[offset], data); }
  99. static WRITE_HANDLER( shared_ram_4_w ) { COMBINE_WORD_MEM(&shared_ram_4[offset], data); }
  100.  
  101.  
  102.  
  103. /*************************************
  104.  *
  105.  *    Initialization
  106.  *
  107.  *************************************/
  108.  
  109. static void update_interrupts(void)
  110. {
  111.     int newstate = 0;
  112.  
  113.     if (atarigen_video_int_state)
  114.         newstate |= 4;
  115.     if (atarigen_sound_int_state)
  116.         newstate |= 6;
  117.  
  118.     if (newstate)
  119.         cpu_set_irq_line(0, newstate, ASSERT_LINE);
  120.     else
  121.         cpu_set_irq_line(0, 7, CLEAR_LINE);
  122. }
  123.  
  124.  
  125. static void init_machine(void)
  126. {
  127.     atarigen_eeprom_reset();
  128.     atarigen_interrupt_reset(update_interrupts);
  129.     atarigen_scanline_timer_reset(vindictr_scanline_update, 8);
  130.     atarijsa_reset();
  131. }
  132.  
  133.  
  134.  
  135. /*************************************
  136.  *
  137.  *    I/O handling
  138.  *
  139.  *************************************/
  140.  
  141. static int fake_inputs(int real_port, int fake_port)
  142. {
  143.     int result = readinputport(real_port);
  144.     int fake = readinputport(fake_port);
  145.  
  146.     if (fake & 0x01)            /* up */
  147.     {
  148.         if (fake & 0x04)        /* up and left */
  149.             result &= ~0x2000;
  150.         else if (fake & 0x08)    /* up and right */
  151.             result &= ~0x1000;
  152.         else                    /* up only */
  153.             result &= ~0x3000;
  154.     }
  155.     else if (fake & 0x02)        /* down */
  156.     {
  157.         if (fake & 0x04)        /* down and left */
  158.             result &= ~0x8000;
  159.         else if (fake & 0x08)    /* down and right */
  160.             result &= ~0x4000;
  161.         else                    /* down only */
  162.             result &= ~0xc000;
  163.     }
  164.     else if (fake & 0x04)        /* left only */
  165.         result &= ~0x6000;
  166.     else if (fake & 0x08)        /* right only */
  167.         result &= ~0x9000;
  168.  
  169.     return result;
  170. }
  171.  
  172.  
  173. static READ_HANDLER( special_input_r )
  174. {
  175.     int result = 0;
  176.  
  177.     switch (offset & 0x10)
  178.     {
  179.         case 0x00:
  180.             result = fake_inputs(0, 3);
  181.             break;
  182.  
  183.         case 0x10:
  184.             result = fake_inputs(1, 4);
  185.             if (atarigen_sound_to_cpu_ready) result ^= 0x0004;
  186.             if (atarigen_cpu_to_sound_ready) result ^= 0x0008;
  187.             result ^= 0x0010;
  188.             break;
  189.     }
  190.  
  191.     return result;
  192. }
  193.  
  194.  
  195.  
  196. /*************************************
  197.  *
  198.  *    Main CPU memory handlers
  199.  *
  200.  *************************************/
  201.  
  202. static struct MemoryReadAddress main_readmem[] =
  203. {
  204.     { 0x000000, 0x09ffff, MRA_ROM },
  205.     { 0x0e0000, 0x0e0fff, atarigen_eeprom_r },
  206.     { 0x260000, 0x26001f, special_input_r },
  207.     { 0x260020, 0x26002f, input_port_2_r },
  208.     { 0x260030, 0x260031, atarigen_sound_r },
  209.     { 0x3e0000, 0x3e0fff, MRA_BANK1 },
  210.     { 0x3f0000, 0x3f1fff, shared_ram_1_r },
  211.     { 0x3f2000, 0x3f3fff, shared_ram_2_r },
  212.     { 0x3f4000, 0x3f4fff, shared_ram_3_r },
  213.     { 0x3f5000, 0x3f7fff, shared_ram_4_r },
  214.     { 0xff8000, 0xff9fff, shared_ram_1_r },
  215.     { 0xffa000, 0xffbfff, shared_ram_2_r },
  216.     { 0xffc000, 0xffcfff, shared_ram_3_r },
  217.     { 0xffd000, 0xffffff, shared_ram_4_r },
  218.     { -1 }  /* end of table */
  219. };
  220.  
  221.  
  222. static struct MemoryWriteAddress main_writemem[] =
  223. {
  224.     { 0x000000, 0x09ffff, MWA_ROM },
  225.     { 0x0e0000, 0x0e0fff, atarigen_eeprom_w, &atarigen_eeprom, &atarigen_eeprom_size },
  226.     { 0x1f0000, 0x1fffff, atarigen_eeprom_enable_w },
  227.     { 0x2e0000, 0x2e0001, watchdog_reset_w },
  228.     { 0x360000, 0x360001, atarigen_video_int_ack_w },
  229.     { 0x360010, 0x360011, MWA_NOP },
  230.     { 0x360020, 0x360021, atarigen_sound_reset_w },
  231.     { 0x360030, 0x360031, atarigen_sound_w },
  232.     { 0x3e0000, 0x3e0fff, vindictr_paletteram_w, &paletteram },
  233.     { 0x3f0000, 0x3f1fff, vindictr_playfieldram_w, &atarigen_playfieldram, &atarigen_playfieldram_size },
  234.     { 0x3f2000, 0x3f3fff, shared_ram_2_w, &atarigen_spriteram, &atarigen_spriteram_size },
  235.     { 0x3f4000, 0x3f4fff, shared_ram_3_w, &atarigen_alpharam, &atarigen_alpharam_size },
  236.     { 0x3f5000, 0x3f7fff, shared_ram_4_w, &shared_ram_4 },
  237.     { 0xff8000, 0xff9fff, vindictr_playfieldram_w },
  238.     { 0xffa000, 0xffbfff, shared_ram_2_w },
  239.     { 0xffc000, 0xffcfff, shared_ram_3_w },
  240.     { 0xffd000, 0xffffff, shared_ram_4_w },
  241.     { -1 }  /* end of table */
  242. };
  243.  
  244.  
  245.  
  246. /*************************************
  247.  *
  248.  *    Port definitions
  249.  *
  250.  *************************************/
  251.  
  252. INPUT_PORTS_START( vindictr )
  253.     PORT_START        /* 26000 */
  254.     PORT_BIT( 0x00ff, IP_ACTIVE_LOW, IPT_UNUSED )
  255.     PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
  256.     PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER1 )
  257.     PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
  258.     PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_BUTTON4 | IPF_PLAYER1 )
  259.     PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_UP    | IPF_PLAYER1 | IPF_2WAY )
  260.     PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_JOYSTICKRIGHT_UP   | IPF_PLAYER1 | IPF_2WAY )
  261.     PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_DOWN  | IPF_PLAYER1 | IPF_2WAY )
  262.     PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_JOYSTICKRIGHT_DOWN | IPF_PLAYER1 | IPF_2WAY )
  263.  
  264.     PORT_START        /* 26010 */
  265.     PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_VBLANK )
  266.     PORT_SERVICE( 0x0002, IP_ACTIVE_LOW )
  267.     PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_UNUSED )
  268.     PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_UNUSED )
  269.     PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_UNUSED )
  270.     PORT_BIT( 0x00e0, IP_ACTIVE_LOW, IPT_UNUSED )
  271.     PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
  272.     PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER2 )
  273.     PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
  274.     PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_BUTTON4 | IPF_PLAYER2 )
  275.     PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_UP    | IPF_PLAYER2 | IPF_2WAY )
  276.     PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_JOYSTICKRIGHT_UP   | IPF_PLAYER2 | IPF_2WAY )
  277.     PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_JOYSTICKLEFT_DOWN  | IPF_PLAYER2 | IPF_2WAY )
  278.     PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_JOYSTICKRIGHT_DOWN | IPF_PLAYER2 | IPF_2WAY )
  279.  
  280.     PORT_START        /* 26020 */
  281.     PORT_BIT( 0x00ff, IP_ACTIVE_LOW, IPT_UNUSED )
  282.     PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_START1 )
  283.     PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_START2 )
  284.     PORT_BIT( 0xfc00, IP_ACTIVE_LOW, IPT_UNUSED )
  285.  
  286.     PORT_START        /* single joystick */
  287.     PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP | IPF_8WAY | IPF_CHEAT | IPF_PLAYER1 )
  288.     PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_CHEAT | IPF_PLAYER1 )
  289.     PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_CHEAT | IPF_PLAYER1 )
  290.     PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_CHEAT | IPF_PLAYER1 )
  291.  
  292.     PORT_START        /* single joystick */
  293.     PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP | IPF_8WAY | IPF_CHEAT | IPF_PLAYER2 )
  294.     PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_CHEAT | IPF_PLAYER2 )
  295.     PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_CHEAT | IPF_PLAYER2 )
  296.     PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_CHEAT | IPF_PLAYER2 )
  297.  
  298.     JSA_I_PORT        /* audio port */
  299. INPUT_PORTS_END
  300.  
  301.  
  302.  
  303. /*************************************
  304.  *
  305.  *    Graphics definitions
  306.  *
  307.  *************************************/
  308.  
  309. static struct GfxLayout anlayout =
  310. {
  311.     8,8,    /* 8*8 chars */
  312.     1024,    /* 1024 chars */
  313.     2,        /* 2 bits per pixel */
  314.     { 0, 4 },
  315.     { 0, 1, 2, 3, 8, 9, 10, 11 },
  316.     { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16 },
  317.     8*16    /* every char takes 16 consecutive bytes */
  318. };
  319.  
  320.  
  321. static struct GfxLayout pfmolayout =
  322. {
  323.     8,8,    /* 8*8 sprites */
  324.     32768,    /* 32768 of them */
  325.     4,        /* 4 bits per pixel */
  326.     { 0*8*0x40000, 1*8*0x40000, 2*8*0x40000, 3*8*0x40000 },
  327.     { 0, 1, 2, 3, 4, 5, 6, 7 },
  328.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
  329.     8*8    /* every sprite takes 8 consecutive bytes */
  330. };
  331.  
  332.  
  333. static struct GfxDecodeInfo gfxdecodeinfo[] =
  334. {
  335.     { REGION_GFX1, 0, &pfmolayout,  256, 32 },        /* sprites & playfield */
  336.     { REGION_GFX2, 0, &anlayout,      0, 64 },        /* characters 8x8 */
  337.     { -1 } /* end of array */
  338. };
  339.  
  340.  
  341.  
  342. /*************************************
  343.  *
  344.  *    Machine driver
  345.  *
  346.  *************************************/
  347.  
  348. static struct MachineDriver machine_driver_vindictr =
  349. {
  350.     /* basic machine hardware */
  351.     {
  352.         {
  353.             CPU_M68010,        /* verified */
  354.             ATARI_CLOCK_14MHz/2,
  355.             main_readmem,main_writemem,0,0,
  356.             atarigen_video_int_gen,1
  357.         },
  358.         JSA_I_CPU
  359.     },
  360.     60, DEFAULT_REAL_60HZ_VBLANK_DURATION,    /* frames per second, vblank duration */
  361.     1,
  362.     init_machine,
  363.  
  364.     /* video hardware */
  365.     42*8, 30*8, { 0*8, 42*8-1, 0*8, 30*8-1 },
  366.     gfxdecodeinfo,
  367.     2048, 2048,
  368.     0,
  369.  
  370.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE | VIDEO_UPDATE_BEFORE_VBLANK,
  371.     0,
  372.     vindictr_vh_start,
  373.     vindictr_vh_stop,
  374.     vindictr_vh_screenrefresh,
  375.  
  376.     /* sound hardware */
  377.     JSA_I_STEREO_WITH_POKEY,
  378.  
  379.     atarigen_nvram_handler
  380. };
  381.  
  382.  
  383.  
  384. /*************************************
  385.  *
  386.  *    ROM definition(s)
  387.  *
  388.  *************************************/
  389.  
  390. ROM_START( vindictr )
  391.     ROM_REGION( 0x60000, REGION_CPU1 )    /* 6*64k for 68000 code */
  392.     ROM_LOAD_EVEN( "vin.d1", 0x00000, 0x10000, 0x2e5135e4 )
  393.     ROM_LOAD_ODD ( "vin.d3", 0x00000, 0x10000, 0xe357fa79 )
  394.     ROM_LOAD_EVEN( "vin.j1", 0x20000, 0x10000, 0x44c77ee0 )
  395.     ROM_LOAD_ODD ( "vin.j3", 0x20000, 0x10000, 0x4deaa77f )
  396.     ROM_LOAD_EVEN( "vin.k1", 0x40000, 0x10000, 0x9a0444ee )
  397.     ROM_LOAD_ODD ( "vin.k3", 0x40000, 0x10000, 0xd5022d78 )
  398.  
  399.     ROM_REGION( 0x14000, REGION_CPU2 )    /* 64k + 16k for 6502 code */
  400.     ROM_LOAD( "vin.snd",     0x10000, 0x4000, 0xd2212c0a )
  401.     ROM_CONTINUE(            0x04000, 0xc000 )
  402.  
  403.     ROM_REGION( 0x100000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  404.     ROM_LOAD( "vin.p13",     0x00000, 0x20000, 0x062f8e52 )
  405.     ROM_LOAD( "vin.p14",     0x20000, 0x10000, 0x0e4366fa )
  406.     ROM_RELOAD(              0x30000, 0x10000 )
  407.     ROM_LOAD( "vin.p8",      0x40000, 0x20000, 0x09123b57 )
  408.     ROM_LOAD( "vin.p6",      0x60000, 0x10000, 0x6b757bca )
  409.     ROM_RELOAD(              0x70000, 0x10000 )
  410.     ROM_LOAD( "vin.r13",     0x80000, 0x20000, 0xa5268c4f )
  411.     ROM_LOAD( "vin.r14",     0xa0000, 0x10000, 0x609f619e )
  412.     ROM_RELOAD(              0xb0000, 0x10000 )
  413.     ROM_LOAD( "vin.r8",      0xc0000, 0x20000, 0x2d07fdaa )
  414.     ROM_LOAD( "vin.r6",      0xe0000, 0x10000, 0x0a2aba63 )
  415.     ROM_RELOAD(              0xf0000, 0x10000 )
  416.  
  417.     ROM_REGION( 0x04000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  418.     ROM_LOAD( "vin.n17",     0x00000, 0x04000, 0xf99b631a )        /* alpha font */
  419. ROM_END
  420.  
  421.  
  422.  
  423. /*************************************
  424.  *
  425.  *    Driver initialization
  426.  *
  427.  *************************************/
  428.  
  429. static void rom_decode(void)
  430. {
  431.     int i;
  432.  
  433.     /* invert the graphics bits on the playfield and motion objects */
  434.     for (i = 0; i < memory_region_length(REGION_GFX1); i++)
  435.         memory_region(REGION_GFX1)[i] ^= 0xff;
  436. }
  437.  
  438. static void init_vindictr(void)
  439. {
  440.     atarigen_eeprom_default = NULL;
  441.  
  442.     atarijsa_init(1, 5, 1, 0x0002);
  443.  
  444.     /* speed up the 6502 */
  445.     atarigen_init_6502_speedup(1, 0x4150, 0x4168);
  446.  
  447.     /* display messages */
  448.     atarigen_show_sound_message();
  449.  
  450.     rom_decode();
  451. }
  452.  
  453.  
  454.  
  455. GAME( 1988, vindictr, 0, vindictr, vindictr, vindictr, ROT0, "Atari Games", "Vindicators" )
  456.